//线段树-维护更多信息(无聊的数列-区间修改+单点查询)
//解法一:
#include <iostream>
using namespace std;
typedef long long ll;
#define lc p << 1
#define rc p << 1 | 1
const int N = 1e5 + 10;
ll a[N];

struct tree
{
    int l, r;
    ll sum, k, d; //首项为k, 公差为d, 两个懒标记
}tr[N << 2];

void pushup(int p)
{
    tr[p].sum = tr[lc].sum + tr[rc].sum;
}

void build(int p, int l, int r)
{
    tr[p] = {l, r, a[l], 0, 0};
    if(l == r) return;
    int mid = (l + r) >> 1;
    build(lc, l, mid); build(rc, mid + 1, r);
    pushup(p); 
}

void lazy(int p, ll k, ll d)
{
    tr[p].sum += (k + k + (tr[p].r - tr[p].l) * d) * (tr[p].r - tr[p].l + 1) / 2;
    tr[p].k += k;
    tr[p].d += d;
}

void pushdown(int p)
{
    int l = tr[p].l, r = tr[p].r;
    int mid = (l + r) >> 1;
    lazy(lc, tr[p].k, tr[p].d);
    lazy(rc, tr[p].k + (mid + 1 - l) * tr[p].d, tr[p].d);
    tr[p].k = tr[p].d = 0;
}

void modify(int p, int x, int y, ll k, ll d)
{
    int l = tr[p].l, r = tr[p].r;
    if(x <= l && r <= y) 
    {
        lazy(p, k + (l - x) * d, d);
        return;
    }
    pushdown(p);
    int mid = (l + r) >> 1;
    if(x <= mid) modify(lc, x, y, k, d);
    if(y > mid) modify(rc, x, y, k, d);  //此处就是k!!!
    pushup(p);
}

ll query(int p, int x)
{
    int l = tr[p].l, r = tr[p].r;
    if(x == l && r == x) return tr[p].sum;
    pushdown(p);
    int mid = (l + r) >> 1;
    if(x <= mid) return query(lc, x);
    else return query(rc, x);
}

int main()
{
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> a[i];
    build(1, 1, n);
    while(m--)
    {
        int op; cin >> op;
        if(op == 1)
        {
            int l, r, k, d; cin >> l >> r >> k >> d;
            modify(1, l, r, k, d);
        }
        else
        {
            int p; cin >> p;
            cout << query(1, p) << endl;
        }
    }
    return 0;
}


//解法二:维护差分数组, 区间修改+区间查询
#include <iostream>
using namespace std;
#define lc p << 1
#define rc p << 1 | 1
const int N = 1e5 + 10;
typedef long long ll;
ll a[N];

struct tree
{
    int l, r;
    ll sum, add; //add是懒标记
}tr[N << 2];

void pushup(int p)
{
    tr[p].sum = tr[lc].sum + tr[rc].sum;
}

void build(int p, int l, int r)
{
    tr[p] = {l, r, a[l], 0};
    if(l == r) return;
    int mid = (l + r) >> 1; 
    build(lc, l, mid); build(rc, mid +1, r);
    pushup(p);
}

void lazy(int p, int k)
{
    tr[p].sum += (tr[p].r - tr[p].l + 1) * k;
    tr[p].add += k;
}

void pushdown(int p)
{
    lazy(lc, tr[p].add);
    lazy(rc, tr[p].add);
    tr[p].add = 0;
}

void modify(int p, int x, int y, int k)
{
    int l = tr[p].l, r = tr[p].r;
    if(x <= l && r <= y) 
    {
        lazy(p, k);        
        return;
    }
    pushdown(p);
    int mid = (l + r) >> 1;
    if(x <= mid) modify(lc, x, y, k);
    if(y > mid) modify(rc, x, y, k);
    pushup(p);
}

ll query(int p, int x, int y)
{
    int l = tr[p].l, r = tr[p].r;
    if(x <= l && r <= y) return tr[p].sum;
    pushdown(p);
    int mid = (l + r) >> 1;
    ll sum = 0;
    if(x <= mid) sum += query(lc, x, y);
    if(y > mid) sum += query(rc, x, y);
    return sum;
}

int main()
{
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++) 
    {
        int x; cin >> x;
        a[i] += x, a[i + 1] -= x;
    }
    build(1, 1, n);
    while(m--)
    {
        int op; cin >> op;
        if(op == 1)
        {
            int l, r, k, d; cin >> l >> r >> k >> d;
            modify(1, l, l, k);
            if(l + 1 <= r) modify(1, l + 1, r, d);
            if(r + 1 <= n) modify(1, r + 1, r + 1, -(k + (r - l) * d));
        }
        else
        {
            int p; cin >> p;
            cout << query(1, 1, p) << endl;
        }
    }
}

